package com.exercise.DesignPattern.StructuralPatterns.CompositePattern;

import java.util.ArrayList;
import java.util.List;

//容器节点
public class Composite implements Component{

    private final List<Component> children = new ArrayList<>();

    @Override
    public void operation() {
        for (Component a : children) {
            a.operation();
        }
    }

    public void add(Component component) {
        children.add(component);
    }

    public void remove(Component component) {
        children.remove(component);
    }

}
